// Author: Domien Nowicki, Bjorn Schobben


#include <QGridLayout>
#include "GLRendererWidget.h"



GLRendererWidget::GLRendererWidget(QWidget *parent, const QGLWidget * shareWidget, Qt::WFlags flags): RendererWidget(parent, flags), glWidget(0)
{
	glWidget = new GLRendererWidgetImpl(parent, shareWidget, flags);

    QGridLayout *mainLayout = new QGridLayout;
	mainLayout->setMargin(0);
	mainLayout->setSpacing(0);
    mainLayout->addWidget(glWidget, 0,0);
    setLayout(mainLayout);
}

GLRendererWidget::~GLRendererWidget()
{
	if (0 != glWidget)
	{
		delete glWidget;
	}
}

void GLRendererWidget::Update()
{
	glWidget->Update();
}


void GLRendererWidget::SetPixel(unsigned int x, unsigned int y, const Pixel& pixel)
{
	glWidget->SetPixel(x, y, pixel);
}


Pixel GLRendererWidget::GetPixel(unsigned int x, unsigned int y) const
{
	return glWidget->GetPixel(x, y);
}

unsigned int GLRendererWidget::GetHeight() const
{
	return glWidget->GetHeight();
}

unsigned int GLRendererWidget::GetWidth() const
{
	return glWidget->GetWidth();
}

void GLRendererWidget::DrawPolygon(const Poly& poly)
{
	glWidget->DrawPolygon(poly);
}